package com.css.apps.base.user.action.report;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.css.apps.base.user.service.UserCountGraphService;
import com.css.db.util.StringHelper;
import com.css.webbase.webwork.action.AdminAction;

@SuppressWarnings("serial")
public class DirAuthSysUserCount extends AdminAction {

	private transient UserCountGraphService service = new UserCountGraphService();
	/*** 1. 只显示表格; 2. 图表展示 */
	private String showMod;
	private boolean report;
	/**
	 * 1. 按授权系统 
	 * 2. 用户状态 
	 * 3. 以集团和二级企业为维度统计用户状态
	 * 4. 按照时间段统计用户注册总数 
	 * 5. 按照时间段以集团和二级企业为维度统计用户注册数量
	 */
	private String showType;
	private Date startTime;
	private List<String> tabHeader = new ArrayList<>();
	private List<Object[]> tabData = new ArrayList<>();
	private Object axisX, axisY;
	
	@Override
	protected String adminGo() {
		if (StringHelper.isEmpty(showType)) {
			showType = "1";
		}
		initTabHeader();
		initTabData();
		return SUCCESS;
	}

	private void initTabData() {
		tabData.clear();
		String[] res = new String[2];
		if("1".equals(showType)) {
			tabData = service.getAuthSysUserCountTabData();
			res = service.getAuthSysUserCountChartData();
		}
		axisX = res[0];
		axisY = res[1];
	}
	
	private void initTabHeader() {
		tabHeader.clear();
		if("1".equals(showType)) {
			tabHeader.add("系统名称"); tabHeader.add("人数"); tabHeader.add("占总用户比重");
		}
	}
	
	public String getShowType() {
		return showType;
	}

	public void setShowType(String showType) {
		this.showType = showType;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public List<String> getTabHeader() {
		return tabHeader;
	}

	public void setTabHeader(List<String> tabHeader) {
		this.tabHeader = tabHeader;
	}

	public List<Object[]> getTabData() {
		return tabData;
	}

	public void setTabData(List<Object[]> tabData) {
		this.tabData = tabData;
	}

	public Object getAxisX() {
		return axisX;
	}

	public void setAxisX(Object axisX) {
		this.axisX = axisX;
	}

	public Object getAxisY() {
		return axisY;
	}

	public void setAxisY(Object axisY) {
		this.axisY = axisY;
	}

	public String getShowMod() {
		if("1".equals(showType) || "2".equals(showType)) {
			showMod = "2";
		} else {
			showMod = "1";
		}
		return showMod;
	}

	public boolean isReport() {
		if("1".equals(showType) || "2".equals(showType)) {
			report = true;
		} else {
			report = false;
		}
		return report;
	}

}
